package com.excell.support.excellbasic;

import lombok.Data;

/**
 * @User c.c
 * @Since 2022/12/6
 * @Time 14:52
 * @Description 列基本元素
 */

@Data
public class ColumnCell {
  //起始位置
  private Integer start;
  //结束位置
  private Integer end;

  private ColumnCell(Integer start, Integer end) {
    this.start = start.equals(0) ? 0 : start - 1;
    this.end = end.equals(0) ? 0 : end - 1;
  }

  private ColumnCell() {
    this.start = 0;
    this.end = 0;
  }


  /**
   * @author C.c
   * @since 2022-12-07 12:00
   * @param sameColumn 相同列
  **/
  public ColumnCell(Integer sameColumn) {
    this.start = sameColumn.equals(0) ? 0 : sameColumn - 1;
    this.end = sameColumn.equals(0) ? 0 : sameColumn - 1;
  }

  /**
   *
   * @author C.c
   * @since 2022-12-07 14:09
   * @param startMerge 开始合并列
   * @param endMerge 结束合并列
   * @return ColumnCell
   **/
  public static ColumnCell intiColumn(Integer startMerge,Integer endMerge){
    return new ColumnCell(startMerge,endMerge);
  }

  public static ColumnCell intiColumn(Integer sameColumn){
    return intiColumnSame(sameColumn);
  }

  /**
   *
   * @author C.c
   * @since 2022-12-07 14:09
   * @param sameColumn 相同列
   * @return ColumnCell
   **/
  private static ColumnCell intiColumnSame(Integer sameColumn){
    return new ColumnCell(sameColumn);
  }
}
